#include "systemcontrols.h"
#include "configuration.h"

#include "controls/ftpushbutton.h"
#include "controls/ftpushbuttonicon.h"
#include "controls/ftlabel.h"
#include "controls/ftvboxlayout.h"
#include "controls/fthboxlayout.h"
#include "controls/fttextarea.h"


SystemControls::SystemControls() :
    RotatingWidget()
{
    buildButtons();
    buildInfo();
}

SystemControls::~SystemControls()
{
}

void SystemControls::buildInfo()
{
    titleArea = new FTLabel("");
    titleArea->setTitle(true);
    titleArea->setAlignment( Qt::AlignHCenter );
    infoArea = new FTTextArea("", -1);

#ifdef CAP_SUPPORTER
    titleArea->setText( tr("Thank you Supporter!") );
    infoArea->setText( tr("Track@Way is developer for fun by Willy Gardiol. Thank you for supporting this software! Please report any issues or ideas to the support forum at http://forums.trackaway.org! Your support and contribution is vital to Track@Way!") );
#else
    titleArea->setText( tr("Support Track@Way!" ));
    infoArea->setText( tr("This software is developed by Willy Gardiol in his own free time and for fun. I hate ads as well as you... So i put it where it should not bother you too much. If you like Track@Way, please spend a few seconds to click on the ad, or purchase the Supporter edition!" ) );
#endif

}

void SystemControls::buildButtons()
{
    // About button...
    openAbout = new FTPushButton( tr("Help and Info") );
    openAbout->setIcon( QIcon( ":/misc/help.png") );
    connect( openAbout, SIGNAL(clicked()),
             this, SIGNAL(showAbout()) );

    // Config button
    openConfig = new FTPushButton( tr("Configuration...") );
    openConfig->setIcon( QIcon(":/system/config_dialog") );
    connect( openConfig, SIGNAL(clicked()),
             this, SIGNAL(showConfig()) );

    // exit button:
    openQuit = new FTPushButton( tr("Close Track@Away") );
    openQuit->setIcon( QIcon( ":/system/exit") );
    connect( openQuit, SIGNAL(clicked()),
             this, SIGNAL(askQuit()) );
}

QLayout* SystemControls::createHorizontal()
{
    FTVBoxLayout* grid = new FTVBoxLayout();
    FTHBoxLayout* hgrid = new FTHBoxLayout();
    grid->addWidget( openQuit );
    hgrid->addWidget( openAbout );
    hgrid->addWidget( openConfig );
    grid->addLayout( hgrid );
    grid->addWidget( titleArea );
    grid->addWidget( infoArea );
    return grid;
}

QLayout* SystemControls::createVertical()
{
    FTVBoxLayout* grid = new FTVBoxLayout();
    grid->addWidget( openQuit );
    grid->addWidget( openAbout );
    grid->addWidget( openConfig );
    grid->addWidget( titleArea );
    grid->addWidget( infoArea );
    return grid;
}
